package org.ens.delegation.bo;

import java.util.Date;
import java.util.List;

import javax.persistence.*;

/**
 * @author amine
 *
 */
@Entity
@Table(name="agent")
public class Agent implements IBusinessObject<Integer>{

	private Integer id;
	private String cin;
	private String nomFr;
	private String nomAr;
	private String sexe;
	private Date dateNaiss;
	private Date dateRec;
	private Date dateNom;
	private Date dateTit;
	private Date dateAff;
	private Integer nombreEnfant;
	private String profesConj;
	private boolean travailEnMEN;
	
	private List<AgentGrade> listGrade;
	private List<AgentEchellon> listEchellon;
	private Etablissement etablissementAffecte;
	private Etablissement etablissementAttache;
	private Fonction fonction;
	private Service service;
	

	@Override
	@Id
	@Column(name="num_doti")
	public Integer getId() {
		return id;
	}

	@Override
	public void setId(Integer pk) {
		this.id = pk;
	}

	@Column(name="cin")
	public String getCin() {
		return cin;
	}

	public void setCin(String cin) {
		this.cin = cin;
	}

	@Column(name="nom_fr")
	public String getNomFr() {
		return nomFr;
	}

	public void setNomFr(String nomFr) {
		this.nomFr = nomFr;
	}

	@Column(name="nom_ar")
	public String getNomAr() {
		return nomAr;
	}

	public void setNomAr(String nomAr) {
		this.nomAr = nomAr;
	}

	@Column(name="sexe")
	public String getSexe() {
		return sexe;
	}

	public void setSexe(String sexe) {
		this.sexe = sexe;
	}

	@Column(name="date_naiss")
        @Temporal(javax.persistence.TemporalType.DATE)
	public Date getDateNaiss() {
		return dateNaiss;
	}

	public void setDateNaiss(Date dateNaiss) {
		this.dateNaiss = dateNaiss;
	}

	@Column(name="date_rec")
        @Temporal(javax.persistence.TemporalType.DATE)
	public Date getDateRec() {
		return dateRec;
	}

	public void setDateRec(Date dateRec) {
		this.dateRec = dateRec;
	}

	@Column(name="date_nom")
        @Temporal(javax.persistence.TemporalType.DATE)
	public Date getDateNom() {
		return dateNom;
	}

	public void setDateNom(Date dateNom) {
		this.dateNom = dateNom;
	}

	@Column(name="date_tit")
        @Temporal(javax.persistence.TemporalType.DATE)
	public Date getDateTit() {
		return dateTit;
	}

	public void setDateTit(Date dateTit) {
		this.dateTit = dateTit;
	}

	@Column(name="date_affe")
        @Temporal(javax.persistence.TemporalType.DATE)
	public Date getDateAff() {
		return dateAff;
	}

	public void setDateAff(Date dateAff) {
		this.dateAff = dateAff;
	}

	@Column(name="nbr_enfant")
	public Integer getNombreEnfant() {
		return nombreEnfant;
	}

	public void setNombreEnfant(Integer nombreEnfant) {
		this.nombreEnfant = nombreEnfant;
	}

	@Column(name="profession_conjoint")
	public String getProfesConj() {
		return profesConj;
	}

	public void setProfesConj(String profesConj) {
		this.profesConj = profesConj;
	}

	@Column(name="travail_en_men")
	public boolean isTravailEnMEN() {
		return travailEnMEN;
	}

	public void setTravailEnMEN(boolean travailEnMEN) {
		this.travailEnMEN = travailEnMEN;
	}

	@OneToMany(mappedBy="agent")
	public List<AgentGrade> getListGrade() {
		return listGrade;
	}

	public void setListGrade(List<AgentGrade> listGrade) {
		this.listGrade = listGrade;
	}

	@OneToMany(mappedBy="agent")
	public List<AgentEchellon> getListEchellon() {
		return listEchellon;
	}

	public void setListEchellon(List<AgentEchellon> listEchellon) {
		this.listEchellon = listEchellon;
	}

	@ManyToOne
	@JoinColumn(name="etablissement_affecte")
	public Etablissement getEtablissementAffecte() {
		return etablissementAffecte;
	}

	public void setEtablissementAffecte(Etablissement etablissementAffecte) {
		this.etablissementAffecte = etablissementAffecte;
	}

	@ManyToOne
	@JoinColumn(name="etablissement_attache")
	public Etablissement getEtablissementAttache() {
		return etablissementAttache;
	}

	public void setEtablissementAttache(Etablissement etablissementAttache) {
		this.etablissementAttache = etablissementAttache;
	}

	@ManyToOne
	@JoinColumn(name="service")
	public Service getService() {
		return service;
	}

	public void setService(Service service) {
		this.service = service;
	}
	
	@ManyToOne
	@JoinColumn(name="fonction")
	public Fonction getFonction() {
		return fonction;
	}

	public void setFonction(Fonction fonction) {
		this.fonction = fonction;
	}

	@Override
	public boolean equals(Object obj) {
		if(obj == null || !(obj instanceof Agent))
			return false;
		Agent agent = (Agent) obj;
		if(agent.getId() == null)
			return false;
	
		return agent.getId().equals(this.getId());
	}
	
}
